<template>
	<view class="wrap">
		<u-form :model="model" ref="uForm" :errorType="errorType">
			<u-form-item label-width="150" :label-position="labelPosition" label="问题说明" prop="intro">
				<u-input type="textarea" :border="border" placeholder="请填写问题或隐患" v-model="model.intro" />
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="整改前" prop="sex">
				<u-upload ref="uUpload" width="160" height="160" upload-text="上传资料" :action="model.action" :auto-upload="false" ></u-upload>
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="整改后" prop="sex">
				<u-upload ref="uUpload" width="160" height="160" upload-text="上传资料" :action="model.action" :auto-upload="false" ></u-upload>
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="流程状态" prop="sex">
				<u-input :border="border" type="select" :select-open="actionSheetShow" v-model="model.sex" placeholder="请选择整改状态" @click="actionSheetShow = true"></u-input>
			</u-form-item>
			<view class="footBtn">
				<u-button class=" u-m-t-20" @click="submit" type="success">提交</u-button>
				<u-button class=" u-m-t-20" @click="submit" type="warning">审核通过</u-button>
			</view>
		</u-form>
		<u-action-sheet :list="actionSheetList" v-model="actionSheetShow" @click="actionSheetCallback"></u-action-sheet>
		<u-action-sheet :list="personLiable" v-model="personLiableShow" @click="personLiableCallback"></u-action-sheet>
		<u-select mode="single-column" :list="selectList" v-model="selectShow" @confirm="selectConfirm"></u-select>
		<u-picker mode="region"  v-model="pickerShow" @confirm="regionConfirm"></u-picker>
		<u-picker mode="time" v-model="timerShow" :params="params" @confirm="timerConfirm"></u-picker>
		<u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
	</view>
</template>

<script>
export default {
	data() {
		let that = this;
		return {
			model: {
				action:'',
				name: '',
				sex: '',
				person:'',
				likeFruit: '',
				intro: '',
				payType: '支付宝',
				agreement: false,
				region: '',
				timer:'',
				goodsType: '',
				phone: '',
				code: '',
				password: '',
				rePassword: '',
				remember: false,
				photo: ''
			},
      list: [
				{
					name: '发起提交'
				},
				{
					name: '查看数据'
				},
			],
			current: 0,
			swiperCurrent: 0,
			selectList: [
				{
					value: '电子产品',
					label: '电子产品'
				},
				{
					value: '服装',
					label: '服装'
				},
				{
					value: '工艺品',
					label: '工艺品'
				}
			],
			border: false,
			check: false,
			selectStatus: 'close',
			defaultTime: '2019-12-11 20:15:35',
			checkboxList: [
				{
					name: '荔枝',
					checked: false,
					disabled: false
				},
				{
					name: '香蕉',
					checked: false,
					disabled: false
				},
				{
					name: '橙子',
					checked: false,
					disabled: false
				},
				{
					name: '草莓',
					checked: false,
					disabled: false
				}
			],
			radioList: [
				{
					name: '支付宝',
					checked: true,
					disabled: false
				},
				{
					name: '微信',
					checked: false,
					disabled: false
				},
				{
					name: '银联',
					checked: false,
					disabled: false
				},
				{
					name: '现金',
					checked: false,
					disabled: false
				}
			],
			radio: '支付宝',
			params: {
				year: true,
				month: true,
				day: true,
				hour: true,
				minute: true,
				second: true,
			},
      dx:0,
      loadStatus: ['loadmore','loadmore','loadmore','loadmore'],
			actionSheetList: [
				{
					text: '整改中'
				},
				{
					text: '已审核'
				},
				{
					text: '整改完毕'
				}
			],
			actionSheetShow: false,
			personLiable:[{text:'张科长'},{text:'指导员'}],
			personLiableShow:false,
			pickerShow: false,
			timerShow:false,
			selectShow: false,
			radioCheckWidth: 'auto',
			radioCheckWrap: false,
			labelPosition: 'left',
			codeTips: '',
			errorType: ['message'],
		};
	},
	onLoad() {

	},
	computed: {
		borderCurrent() {
			return this.border ? 0 : 1;
		}
	},
	onReady() {
		// this.$refs.uForm.setRules(this.rules);
	},
	methods: {
		submit() {
			this.$refs.uForm.validate(valid => {
				if (valid) {
					if(!this.model.agreement) return this.$u.toast('请勾选协议');
					console.log('验证通过');
				} else {
					console.log('验证失败');
				}
			});
		},

		// 选择地区回调
		regionConfirm(e) {
			this.model.region = e.province.label + '-' + e.city.label + '-' + e.area.label;
		},
		timerConfirm(e){},
		// 选择商品类型回调
		selectConfirm(e) {
			this.model.goodsType = '';
			e.map((val, index) => {
				this.model.goodsType += this.model.goodsType == '' ? val.label : '-' + val.label;
			})
		},
		reachBottom() {
			
		},
		radioCheckboxChange(index) {
			if(index == 0) {
				this.radioCheckWrap = false;
				this.radioCheckWidth = 'auto';
			} else if(index == 1) {
				this.radioCheckWrap = true;
				this.radioCheckWidth = 'auto';
			} else if(index == 2) {
				this.radioCheckWrap = false;
				this.radioCheckWidth = '50%';
			}
		},
		labelPositionChange(index) {
			this.labelPosition = index == 0 ? 'left' : 'top';
		},
		codeChange(text) {
			this.codeTips = text;
		},
		// 获取验证码
		getCode() {
			if(this.$refs.uCode.canGetCode) {
				// 模拟向后端请求验证码
				uni.showLoading({
					title: '正在获取验证码',
					mask: true
				})
				setTimeout(() => {
					uni.hideLoading();
					// 这里此提示会被this.start()方法中的提示覆盖
					this.$u.toast('验证码已发送');
					// 通知验证码组件内部开始倒计时
					this.$refs.uCode.start();
				}, 2000);
			} else {
				this.$u.toast('倒计时结束后再发送');
			}
		},
		errorChange(index) {
			if(index == 0) this.errorType = ['message'];
			if(index == 1) this.errorType = ['toast'];
			if(index == 2) this.errorType = ['border-bottom'];
			if(index == 3) this.errorType = ['border'];
		},
    	// tab栏切换
		change(index) {
			this.swiperCurrent = index;
			this.getOrderList(index);
		},
		transition({ detail: { dx } }) {
			this.$refs.tabs.setDx(dx);
		},
		animationfinish({ detail: { current } }) {
			this.$refs.tabs.setFinishCurrent(current);
			this.swiperCurrent = current;
			this.current = current;
		}
	}
};
</script>

<style scoped lang="scss">
.wrap {
	padding:0 20rpx;
	
}

.m-t-20{
	margin-top:20rpx;
}
.fs16{
	font-size:32rpx;
}
.fs12{
	font-size:20rpx;
}
.leaveLog{
	background: #f8f8f8;
  .item{
	  margin-top:20rpx;
	  line-height: 40rpx;
	padding:20rpx;
    border-radius: 0.3em;
    background: #fff;
  }
}
.blue{
	color:#2979FF;
}
.green{
	color:#18B566;
}
.red{
	color:#FA3534;
}
.c999{
	color:#999;
}
.footBtn{
	
}
</style>
